<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>商品详情页</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
<meta name="format-detection" content="telephone=no">
<meta name="renderer" content="webkit">
<meta http-equiv="Cache-Control" content="no-siteapp" />
<link rel="stylesheet" href="{$smarty.const.PUBLIC_PATH}css/amazeui.min.css"/>
<link rel="stylesheet" href="{$smarty.const.IMAGES_PATH}style.css"/>
<script src="{$smarty.const.PUBLIC_PATH}js/jquery.min.js"></script>
<script src="{$smarty.const.PUBLIC_PATH}js/amazeui.min.js"></script>
<script>
	var goods=new Array();
function checkIsInteger(str)
{
  //如果为空，则通过校验
  if(str == "")
    return true;
     if(/^(\-?)(\d+)$/.test(str))
       return true;
     else
       return false;
}
var errordialog=function(c){
	alert(c)
}
//检验商品数量
function checkCounts(id) {
    var Counts = $("#" + id).val();
    if (Counts == "") {
        errordialog("请填写数量!");
        return false;
    }
    else if (!checkIsInteger(Counts)) {
        errordialog("商品数量不是整数!");
        return false;
    }
    else if (Counts < 1) {
        errordialog("商品数量不能小于1!");
        return false;
    }
    else {
        return true;
    }
}
function addQty(){
	checkCounts('txtQty');
	var qty = parseInt($('#txtQty').val());
	$('#txtQty').val(qty+1);
}
function subtractQty(){
	checkCounts('txtQty');
	var qty = parseInt($('#txtQty').val());
	if(qty <=1){
		errordialog("商品数量不能小于1");
		return;
	}
	$('#txtQty').val(qty-1);
}
</script>
<style type="text/css">
	.am-comment-main{
		margin-right: 20px !important;
	}
	.am-comment-main i{
		float: right;
		color:#f09513;
	}
	.am-avg-sm-4>li {
    	width: 33%;
	}
</style>
</head>

<body>
<div class="container">
	<!--引入头文件-->
	{include file="../header.html"}
	<script>$('.title-link').text("商品详情")</script>
	
    <!-- banner -->
    <div data-am-widget="slider" class="am-slider am-slider-a1" data-am-slider='{ &quot;directionNav&quot;:false}'>
      <ul class="am-slides">
        <li>
          <img src="{$good.main_img}">
        </li>
        <!--<li>
          <img src="http://s.amazeui.org/media/i/demos/bing-2.jpg">
        </li>
        <li>
          <img src="http://s.amazeui.org/media/i/demos/bing-3.jpg">
        </li>
        <li>
          <img src="http://s.amazeui.org/media/i/demos/bing-4.jpg">
        </li>-->
      </ul>
    </div>
	<div class="gray-panel">
    	<div class="paoduct-title-panel">
        	<h1 class="product-h1">{$good.name}</h1>
            <p><span class="am-fr product-title-gray-text"><i class="am-icon-star"></i>收藏</span><span class="bold">积分：</span><span class="red2">￥{$good.price}</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="product-title-gray-text"></span></p>
        </div>
        <div class="my-search-title-panel">
        	<ul class="am-avg-sm-4 am-text-center am-text-sm">
            	<li class="am-text-center">销量<br />{$good.salecount}件</li>
                <li class="am-text-center">库存<br />{$good.count}件</li>
                <!--<li class="am-text-center">订单<br />0个</li>-->
                <li class="am-text-center">评价<br />{$good.comment_cnt}条</li>
            </ul>
    	</div>
        <div class="my-search-title-panel">
            <hr data-am-widget="divider" style="" class="am-divider-default am-margin-bottom-sm"/>
            <p class="my-search-titp-p am-text-sm bold">数量</p>
            <div style="overflow:hidden">
            <form class="am-form-inline" role="form" action="{$smarty.const.__MODULE__}/Order/makeorder" method="post">
            	<button type="button" class="am-btn am-btn-default" style="float:left" onClick="subtractQty();" ><i class="am-icon-minus"></i></button>
                <input type="number" name="goods[{$good.id}][quantity]" id="txtQty" class="am-form-field txt-qty am-text-center am-text-sm" value="1" style=" width:60px; margin-right:0px; height:37px; display:inline; float:left">
                <button type="button" class="am-btn am-btn-default" style="float:left" onClick="addQty();"><i class="am-icon-plus"></i></button>
            
            	<p><input name="goods[{$good.id}][id]" value="{$good.id}" style="display: none;"> </p>
              <p><input name="goods[{$good.id}][name]" value="{$good.name}" style="display: none;"> </p>
              <p><input name="goods[{$good.id}][price]" value="{$good.price}" style="display: none;"> </p>
              <p><input name="goods[{$good.id}][main_img]" value="{$good.main_img}" style="display: none;"> </p>
            </form>
            </div>
            <hr data-am-widget="divider" style="" class="am-divider-default am-margin-bottom-sm"/>
            <div>
            	<ul class="am-avg-sm-2 am-text-center">
                	<li class="am-text-center am-padding-sm"><button type="button" data-id="{$good.id}" class="am-btn am-btn-success am-btn-block am-radius addshopcart">加入购物车</button></li>
                    <li class="am-text-center am-padding-sm"><a ><button type="button" class="am-btn am-btn-danger am-btn-block am-radius makeorder">立即购买</button></a></li>
                </ul>
            </div>
        </div>
        <div class="paoduct-title-panel">
        	<h2 class="product-h1">商家信息</h2>
            <p><span class="am-fr product-title-gray-text"><a href="tel:88888888" class=" am-text-success"><i class="am-icon-phone"></i> 电话联系</a></span><span class="product-title-gray-text"><i class="am-icon-crosshairs"></i> 平区回笼观黄平路19号</span></p>
            <hr data-am-widget="divider" style="" class="am-divider-default am-margin-bottom-sm"/>
            <div style="overflow:hidden">
            <!--<ul class="am-avg-sm-2 am-text-center am-padding-bottom-sm">
            	<li class="am-text-center"><a href="#"><i class="am-icon-bank"></i> 进店逛逛</a></li>
                <li class="am-text-center"><a href="#"><i class=" am-icon-comments"></i> 联系卖家</a></li>
            </ul>-->
            </div>
        </div>
    </div>
            <!-- 商品详情 -->
        
        <div data-am-widget="tabs" class="am-tabs am-tabs-d2">
          <ul class="am-tabs-nav am-cf">
            <li class="am-active">
              <a href="[data-tab-panel-0]">详情</a>
            </li>
            <!--<li class="">
              <a href="[data-tab-panel-1]">交易记录</a>
            </li>-->
            <li class="">
              <a href="[data-tab-panel-2]">评价</a>
            </li>
          </ul>
          <div class="am-tabs-bd">
            <div data-tab-panel-0 class="am-tab-panel am-active">{$good.detail}</div>
            <div data-tab-panel-1 class="am-tab-panel ">
            
            <ul class="am-comments-list am-comments-list-flip">
            {foreach $comments as $k=>$v}
            <li class="am-comment">
              <a >
                <img class="am-comment-avatar" src="{$v.touxiang}" alt=""/> <!-- 头像 -->
              </a>
            
              <div class="am-comment-main">
                <header class="am-comment-hd">
                  <div class="am-comment-meta">
                  	<time datetime="2013-07-27T04:54:29-07:00" title="最后的通信时间" class="am-fr">{$v.create_time|date_format:'%Y-%m-%d %H:%M:%S'}</time>
                    <a  class="am-comment-author">{$v.user_name}</a>
					{for $star=1 to 5-$v.score}
                    	<i class="am-icon-star-o " ></i>
					{/for}
                    {for $star=1 to $v.score}
                    	<i class="am-icon-star" ></i>
					{/for}
                  </div>
                </header>
                <div class="am-comment-bd am-text-sm">
                  {$v.content}
                </div>
              </div>
            </li>
            {/foreach}
        </ul>
            
            </div>
          <div data-tab-panel-2 class="am-tab-panel ">
<div class="am-cf am-padding-sm" >
    	<ul class="am-comments-list am-comments-list-flip">
            <li class="am-comment">
              <a href="">
                <img class="am-comment-avatar" src="{$smarty.const.IMAGES_PATH}img1.jpg" alt=""/> <!-- 头像 -->
              </a>
            
              <div class="am-comment-main">
                <header class="am-comment-hd">
                  <div class="am-comment-meta">
                    <a href="#link-to-user" class="am-comment-author">昵称</a>（他的用户名）
                    <time datetime="2013-07-27T04:54:29-07:00" title="最后的通信时间" class="am-fr">2014-7-12 15:30</time>
                  </div>
                </header>
                <div class="am-comment-bd am-text-sm">
                  那，那是一封写给南部母亲的信。我茫然站在骑楼下，我又看到永远的樱子走到街心。
                </div>
              </div>
            </li>
            <li class="am-comment">
              <a href="">
                <img class="am-comment-avatar" src="{$smarty.const.IMAGES_PATH}img1.jpg" alt=""/> <!-- 头像 -->
              </a>
            
              <div class="am-comment-main">
                <header class="am-comment-hd">
                  <div class="am-comment-meta">
                    <a href="#link-to-user" class="am-comment-author">昵称</a>（他的用户名）
                    <time datetime="2013-07-27T04:54:29-07:00" title="最后的通信时间" class="am-fr">2014-7-12 15:30</time>
                  </div>
                </header>
                <div class="am-comment-bd am-text-sm">
                  其实雨下得并不大，却是一生一世中最大的一场雨。而那封信是这样写的，年轻的樱子知不知道呢？
                </div
              ></div>
            </li>
            <li class="am-comment"><!-- 头像显示在右手边 am-comment-flip -->
              <a href="">
                <img class="am-comment-avatar" src="{$smarty.const.IMAGES_PATH}img1.jpg" alt=""/> <!-- 头像 -->
              </a>
            
              <div class="am-comment-main">
                <header class="am-comment-hd">
                  <div class="am-comment-meta">
                    <a href="#link-to-user" class="am-comment-author">昵称</a>（他的用户名）
                    <time datetime="2013-07-27T04:54:29-07:00" title="最后的通信时间" class="am-fr">2014-7-12 15:30</time>
                  </div>
                </header>
                <div class="am-comment-bd  am-text-sm">
                  She's gone 我早知道
                </div>
              </div>
            </li>
        </ul>
    </div>
          </div>
        </div>
        </div>
    
    
    
    <footer data-am-widget="footer" class="am-footer am-footer-default" data-am-footer="{  }">
        <hr data-am-widget="divider" style="" class="am-divider am-divider-default"/>
      <div class="am-footer-miscs ">
        <p>CopyRight©2014 AllMobilize Inc.</p>
        <p>京ICP备13033158</p>
      </div>
    </footer>
    <!--底部-->
    {include file="../footer.html"}
</div>
<script type="text/javascript">
	$('.makeorder').click(function(){
		//登录后才可以购买
		{if $smarty.session.id==null}
			window.location.href="{$smarty.const.__MODULE__}/User/integrallogin";
			return;
		{/if}
	$("form").submit();	
})
	$('.addshopcart').click(function(){
		//登录后才可以添加购物车
		{if $smarty.session.id==null}
			window.location.href="{$smarty.const.__MODULE__}/User/integrallogin";
			// window.navigate("myshop/index.php/User/integrallogin.html");
		{/if}
		var thisgoods=$(this);
		var data={
			id:thisgoods.data('id'),
		}
		$.post("{$smarty.const.__CONTROLLER__}/addshopcart", data, function(ret){
			console.log(ret);
			if(ret){
//				thisgoods.removeClass('am-icon-star-o');
				alert("加入购物车成功");
			}else{
//				thisgoods.addClass('am-icon-star-o');
				alert("加入购物车失败");
			}
		})
	})
</script>
</body>
</html>
